package com.example.hellodemo.recyclerView;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.appcompat.view.menu.MenuView;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.hellodemo.R;

public class PuRecyclerViewAdapter extends RecyclerView.Adapter<PuRecyclerViewAdapter.PuViewHolder> {
    private Context context;
    private ItemOnClick itemOnClick;
    public PuRecyclerViewAdapter(Context context,ItemOnClick itemOnClick){
        this.context = context;
        this.itemOnClick = itemOnClick;

    }
    @NonNull
    @Override
    public PuRecyclerViewAdapter.PuViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new PuViewHolder(LayoutInflater.from(context).inflate(R.layout.pu_item,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull PuRecyclerViewAdapter.PuViewHolder holder, int position) {
        if (position % 2 == 0){
             Glide.with(context).load("https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4024070726,3956765417&fm=26&gp=0.jpg").into(holder.imageView);

        }else {
            Glide.with(context).load("https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1470208717,4098676739&fm=26&gp=0.jpg").into(holder.imageView);
        }
    }

    @Override
    public int getItemCount() {
        return 20;
    }

    class  PuViewHolder extends RecyclerView.ViewHolder{
        private ImageView imageView;
        public PuViewHolder(@NonNull View itemView) {
            super(itemView);
            this.imageView = itemView.findViewById(R.id.pu_image);
        }
    }



    interface  ItemOnClick{
        public  void onClick(int position);
    }
}
